﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.WebSockets;
using System.Net;
using System.Threading;
using Microsoft.Practices.Composite.Events;

namespace KinectMetroApp.ServerRegistry
{
    public class Registry
    {
        public WebSocketServer ServerWebSocket { get; set; }

        public WebSocketClient ClientWebSocket { get; set; }

        public string ServerWebSocketUri { get; set; }

        public string ClientWebSocketUri { get; set; }

        private IEventAggregator eventAggregator=null;

        public Registry()
        {
            eventAggregator = new EventAggregator();
        }

        public async Task Start()
        {
            ServerWebSocketUri = "http://localhost:8052/server/";
            ClientWebSocketUri = "http://localhost:8051/client/";

            ServerWebSocket = new WebSocketServer(eventAggregator);
            ClientWebSocket = new WebSocketClient(eventAggregator);


            await Task.WhenAll(ServerWebSocket.Start(ServerWebSocketUri), ClientWebSocket.Start(ClientWebSocketUri));
        }
    }
}
